varying mat4 projectorMat;
uniform sampler2D sampler;
varying vec4 vertex;

void main() 
{

	mat4 range_mapping = mat4	
				  (0.5, 0.0, 0.0, 0.0,
				   0.0, 0.5, 0.0, 0.0,
				   0.0, 0.0, 0.5, 0.0,
				   0.5, 0.5, 0.5, 1.0);	
	
	vec4 textureCoords = range_mapping * projectorMat * vertex; 
	
	vec2 st = textureCoords.st/textureCoords.q;
	
	
	if (st.s >= 0.0 && st.s <= 1.0 && st.t >= 0.0 && st.t <= 1.0) {
	  
	  
	  vec4 textColor = texture2D(sampler,textureCoords.st/textureCoords.q);			    
	  gl_FragColor = gl_Color * textColor;
	}
	else {
	  gl_FragColor = gl_Color;
	}
}
